﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:ddr="urn:ddrmenu">
  <xsl:output method="html"/>
  <xsl:param name="ControlID" />
  <xsl:param name="Options" />
  <xsl:param name="ShowLoginTab">true</xsl:param>
  <xsl:param name="ShowUserTab">true</xsl:param>
  <xsl:param name="Orientation">Horizontal</xsl:param>
  <xsl:param name="Caption" />
  <xsl:variable name="IsVertical" select="ms:string-compare($Orientation, 'vertical', '', 'i') = 0" />
  <xsl:variable name="DoShowLoginTab" select="ms:string-compare($ShowLoginTab, 'true', '', 'i') = 0" />
  <xsl:variable name="DoShowUserTab" select="ms:string-compare($ShowUserTab, 'true', '', 'i') = 0" />
  <xsl:template match="/*">
    <xsl:apply-templates select="root" />
  </xsl:template>
  <xsl:template match="root">
    <xsl:choose>
      <xsl:when test="$IsVertical">
        <div class="art-vmenublock">
          <div class="art-vmenublock-body">
            <div class="art-vmenublockheader">
              <div class="l"></div>
              <div class="r"></div>
              <div class="t">
                <xsl:value-of select="$Caption"/>
              </div>
            </div>
            <div class="art-vmenublockcontent">
              <div class="art-vmenublockcontent-body">
                <div class="art-vmenu">
                  <div class="art-vmenu-body">
                    <ul class="art-vmenu">
                      <xsl:apply-templates select="node" />
                      <xsl:call-template name="LoginUser" />
                    </ul>
                  </div>
                </div>
                <div class="cleared"></div>
              </div>
            </div>
            <div class="cleared"></div>
          </div>
        </div>
      </xsl:when>
      <xsl:otherwise>
        <script type="text/javascript">
          jQuery(function($){$("#<xsl:value-of select="$ControlID" />").superfish(<xsl:value-of select="$Options" />);});
        </script>
        <style type="text/css">.art-menu UL {top:auto;left:auto}</style>
        <div class="art-nav">
          <div class="l"></div>
          <div class="r"></div>
          <div class="art-nav-center">
            <ul class="art-menu" id="{$ControlID}">
              <xsl:apply-templates select="node" />
              <xsl:call-template name="LoginUser" />
            </ul>
          </div>
        </div>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="node">
    <li>
      <a>
        <xsl:choose>
          <xsl:when test="@enabled = 1">
            <xsl:attribute name="href">
              <xsl:value-of select="@url"/>
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="href">#</xsl:attribute>
            <xsl:attribute name="onclick">return false</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="@breadcrumb = 1">
          <xsl:attribute name="class">active</xsl:attribute>
        </xsl:if>
        <xsl:choose>
          <xsl:when test="@depth = 0">
            <span class="l"></span>
            <span class="r"></span>
            <span class="t">
              <xsl:value-of select="@text" />
            </span>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="@text" />
          </xsl:otherwise>
        </xsl:choose>
      </a>
      <xsl:if test="node">
        <ul>
          <xsl:apply-templates select="node" />
        </ul>
      </xsl:if>
    </li>
  </xsl:template>
  <xsl:template name="LoginUser">
    <xsl:if test="$DoShowLoginTab">
      <li>
        <a href="{ddr:GetLoginURL()}">
          <span class="l"></span>
          <span class="r"></span>
          <span class="t">
            <xsl:value-of select="ddr:GetLoginText()" />
          </span>
        </a>
      </li>
    </xsl:if>
    <xsl:if test="$DoShowUserTab">
      <li>
        <a href="{ddr:GetUserURL()}">
          <span class="l"></span>
          <span class="r"></span>
          <span class="t">
            <xsl:value-of select="ddr:GetUserText()" />
          </span>
        </a>
      </li>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
